eeprom14 2.2.0
Loading...
Searching...
No Matches
eeprom14.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef EEPROM14_H
29#define EEPROM14_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
58
63
68
73#define EEPROM14_MEM_ADDR_START 0x0000
74#define EEPROM14_MEM_ADDR_END 0xFFFF
75#define EEPROM14_MEM_PAGE_SIZE 128
76
82#define EEPROM14_DEVICE_ADDRESS_A2A1A0_000 0x50
83#define EEPROM14_DEVICE_ADDRESS_A2A1A0_001 0x51
84#define EEPROM14_DEVICE_ADDRESS_A2A1A0_010 0x52
85#define EEPROM14_DEVICE_ADDRESS_A2A1A0_011 0x53
86#define EEPROM14_DEVICE_ADDRESS_A2A1A0_100 0x54
87#define EEPROM14_DEVICE_ADDRESS_A2A1A0_101 0x55
88#define EEPROM14_DEVICE_ADDRESS_A2A1A0_110 0x56
89#define EEPROM14_DEVICE_ADDRESS_A2A1A0_111 0x57
90 // eeprom14_set
92
97
102
107#define EEPROM14_MAP_MIKROBUS( cfg, mikrobus ) \
108 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
109 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
110 cfg.wp = MIKROBUS( mikrobus, MIKROBUS_PWM );
111 // eeprom14_map // eeprom14
114
119typedef struct
120{
121 // Output pins
122 digital_out_t wp;
123
124 // Modules
125 i2c_master_t i2c;
126
127 // I2C slave address
129
130} eeprom14_t;
131
136typedef struct
137{
138 pin_name_t scl;
139 pin_name_t sda;
140
141 pin_name_t wp;
142
143 uint32_t i2c_speed;
144 uint8_t i2c_address;
145
147
152typedef enum
153{
156
158
164
175
190
206err_t eeprom14_write_memory ( eeprom14_t *ctx, uint16_t address, uint8_t *data_in, uint8_t len );
207
223err_t eeprom14_read_memory ( eeprom14_t *ctx, uint16_t address, uint8_t *data_out, uint16_t len );
224
234
244
245#ifdef __cplusplus
246}
247#endif
248#endif // EEPROM14_H
249 // eeprom14
251
252// ------------------------------------------------------------------------ END
eeprom14_return_value_t
EEPROM 14 Click return value data.
Definition eeprom14.h:153
@ EEPROM14_ERROR
Definition eeprom14.h:155
@ EEPROM14_OK
Definition eeprom14.h:154
void eeprom14_write_enable(eeprom14_t *ctx)
EEPROM 14 write-enable function.
void eeprom14_cfg_setup(eeprom14_cfg_t *cfg)
EEPROM 14 configuration object setup function.
err_t eeprom14_read_memory(eeprom14_t *ctx, uint16_t address, uint8_t *data_out, uint16_t len)
EEPROM 14 read memory function.
err_t eeprom14_init(eeprom14_t *ctx, eeprom14_cfg_t *cfg)
EEPROM 14 initialization function.
void eeprom14_write_protect(eeprom14_t *ctx)
EEPROM 14 write-protect function.
err_t eeprom14_write_memory(eeprom14_t *ctx, uint16_t address, uint8_t *data_in, uint8_t len)
EEPROM 14 write memory function.
EEPROM 14 Click configuration object.
Definition eeprom14.h:137
uint32_t i2c_speed
Definition eeprom14.h:143
pin_name_t wp
Definition eeprom14.h:141
pin_name_t scl
Definition eeprom14.h:138
pin_name_t sda
Definition eeprom14.h:139
uint8_t i2c_address
Definition eeprom14.h:144
EEPROM 14 Click context object.
Definition eeprom14.h:120
i2c_master_t i2c
Definition eeprom14.h:125
uint8_t slave_address
Definition eeprom14.h:128
digital_out_t wp
Definition eeprom14.h:122